<include file="Public/min-header" />
<div class="wrapper">
	<include file="Public/breadcrumb"/> 
	<style type="text/css">
		.navbar{margin-bottom: 0px;}
	</style>
	<section class="content"> 
       <div class="row"> 
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	               	<nav class="navbar navbar-default">
				        <div class="collapse navbar-collapse">
				          <form class="navbar-form form-inline" action="{:U('Goods/goods_list_quyu_price')}" method="get">
				            <div class="form-group">
				              	<input type="text" name="goods_name" class="form-control" value="{:I('goods_name')}" placeholder="请输产品名称">
				            </div>
							<div class="form-group">
							  	<input type="text" name="store_name" class="form-control" value="{:I('store_name')}" placeholder="请输店铺名称">
							</div>
							<div class="form-group">
							  <select name="zhuangtai" id="zhuangtai" class="form-control">
							    <option value="">选择状态</option>
							        <option value="1" <?php if(I('zhuangtai')==1)echo ' selected="selected" ';   ?> >未设置溢价</option>
									<option value="2" <?php if(I('zhuangtai')==2)echo ' selected="selected" ';   ?>>已设置溢价</option>
							  </select>
							</div>
				            <button type="submit" class="btn btn-primary">查询</button>
				          </form>
				      	</div>
	    			</nav>
	             </div>
	             <div class="box-body">
	           	 <div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable">
		                 <thead>
		                   <tr role="row">
		                       <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>
							   <th style="text-align: center;">产品ID</th>
                               <th style="text-align: center;">产品名称</th>
                               <th style="text-align: center;">店铺名称</th>
			                   <th style="text-align: center;">扣点比例</th>
			                   <th style="text-align: center;">产品价格</th>
                               <th style="text-align: center;">区域溢价</th>
							   <th style="text-align: center;">状态</th>
		                  	   <th style="text-align: center;">操作</th>
		                   </tr>
		                 </thead>
						<tbody>
                          <foreach name="list" item="vo" key="k" >
                             <tr role="row">  
                              <td class="text-center">
                                    <input type="checkbox" name="selected[]" value="{$vo['goods_id']}">
                                </td>
							 <td>{$vo.goods_id}</td>
                             <td><img src="{$vo.original_img}" height="50" style="cursor: pointer;" onmouseover="layer.tips('<img src={$vo.original_img} width=180>',this,{tips: [1, '#EAF8FF']});" onmouseout="layer.closeAll('tips');">  <span onmouseover="layer.tips('关键词:{$vo.keywords}',this,{tips: [1, '#000']});" onmouseout="layer.closeAll('tips');">{$vo.goods_name|getSubstr=0,33}</span>  <span style="color:#ff9800">( {$vo.store_name} )</span></td>
		                     <td>{$vo.store_name}</td>
		                     <td>{$vo.points}</td>
		                     <td>{$vo.shop_price}</td>
							 <td>
								 <?php 
								 foreach($vo['yijia_quyu'] as $vs){
									 foreach($fenbu_list as $vv){
										 if($vs['id']==$vv['fenbu_id']){
											 echo $vv['fenbu_name'].':<span style="color:red">'.$vs['hl'].'</span>,  ';
										 }
									 }
								 }
								 ?>
							 </td>
							 <td>
								 <span>
								 <if condition="$vo[goods_state] eq 0">待审核</if>
								 <if condition="$vo[goods_state] eq 1">审核通过</if>
								 <if condition="$vo[goods_state] eq 2">审核失败</if>
								 <if condition="$vo[goods_state] eq 3">违规下架</if>
								 </span></td>
		                     <td class="text-center">
		                      	<a class="btn btn-info" href="JavaScript:" id="bianji" rel="{$vo.goods_id}" rev="bianji">编辑溢价</a>
		                      	<a class="btn btn-danger" id="bianji" rel="{$vo.goods_id}" rev="del">清除溢价</a>
				     		</td>
		                   </tr>
		                  </foreach>
		                   </tbody>
		                 <tfoot>
		                 
		                 </tfoot>
		               </table>
	               </div>
	          </div>
               <a href="JavaScript:;"  class="btn btn-primary" onclick="plxianzhi()">批量溢价</a>
              <div class="row">
                   
              	    <!--<div class="col-sm-6 text-left">-->
              	    <!--	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>-->
              	    <!--</div>-->
                    <div class="col-sm-6 text-right">{$page}</div>		
              </div>
	          </div>
	        </div>
       	</div>
       </div>
   </section>
   
   <style>
   	#jisuanqi{display: none;}
   	#jisuanqi div{float:left;margin-left:6px;}
   	#jisuanqi input{width:70px;}
   </style>
   <div id="jisuanqi">
   	<div>原价:<input id="yuan_price" type="number" value="" /></div>
   	<div>溢价:<input id="xian_price" type="number" value="" /></div>
   	<div style="color:red;">折扣:<input id="zhekou" type="number" value="0" readonly/></div>
   </div>
<script type="text/javascript">
function plxianzhi(){
    var inputs = $('input:checked');
    var ids ="";
    $.each(inputs,function (k,v) {
        if (v.value != ""){
            ids +=   v.value+",";
        }
    });
    ids = ids.slice(0, -1);
	var myrul='/Admin/Goods/goods_bianji_quyu_prices/goods_id/'+ids;//+myrel;
				layer.open({
				  type: 2,
				  title:'编辑限制区域',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['920px', '620px'], //宽高
				  content: myrul
			})
}
$(document).ready(function() {
	$("#jisuanqi input").on('input',function(e){
	   var yp=$('#yuan_price').val(),xp=$('#xian_price').val();
	   var zhekou=(xp-yp)/yp;
	   $('#zhekou').val(zhekou.toFixed(2));
	});
	
	<?php
		if(session('fenbu_id')==0 && $_SESSION['admin_id']==1){
	?>
	layer.open({
	    type: 1, //Layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）,
	    title: '[溢价] 小学生计算器', //标题
	    area: ['330px', '80px'],   //宽高
		offset: ['10px', '65%'],
	    shade: 0,   //遮罩透明度
	    content: $("#jisuanqi"),//支持获取DOM元素
	    scrollbar: true ,//屏蔽浏览器滚动条
	});
	<?php
	}
	?>
	
	$(".box-body #bianji").click(function(){
			var myrel=$(this).attr('rel'),myrev=$(this).attr('rev'),obj=$(this).parent().parent();
			if(myrev=="bianji"){
				var myrul='/Admin/goods/goods_bianji_quyu_price/goods_id/'+myrel;//+myrel;
					layer.open({
					  type: 2,
					  title:'编辑区域价格',
					  shadeClose: true, //点击遮罩关闭
					  skin: 'layui-layer-rim', //加上边框
					  area: ['920px', '620px'], //宽高
					  content: myrul
				})
			}else{
				$.post('/Admin/goods/goods_bianji_quyu_price',{action:'alldel',goods_id:myrel},function(res){
					layer.msg('清除限制成功！',{icon:6});
					obj.remove();
				})
			}
			
	    });
});
</script>
</div>
</body>
</html>   
